
import os
import click

from auto import Auto
from goods_tool import GoodsDB, FILE_PATH


option_db = click.option('--file', '-f', type=str, prompt='配方表', default='配方表.xlsx', help='配方表名')
option_title = click.option('--title', '-t', type=str, prompt='AUC搜索组', default='地精搜索', help='AUC搜索组名')


@click.command(name='search')
@option_db
@option_title
def search(file: str, title: str):
    """ AUC搜索语法 """
    goods_db = GoodsDB(execl_file=os.path.join(FILE_PATH, file))
    goods_db.auc_search_str(title=title)


@click.command(name='profit')
@option_db
def profit(file: str):
    """ 物品利润 """
    goods_db = GoodsDB(execl_file=os.path.join(FILE_PATH, file))
    goods_db.get_profit()


option_win_title = click.option('--title', '-t', type=str, prompt='窗口标题图片', default='分解窗口.png', help='窗口标题截图')
option_win_button = click.option('--button', '-b', type=str, prompt='按钮图片', default='分解下一个.png', help='按钮截图')
option_click_interval = click.option('--interval', '-i', type=int, prompt='点击间隔', default=2, help='设置点击间隔: 秒')


@click.command(name='auto')
@option_win_title
@option_win_button
@option_click_interval
def auto_click(title: str, button: str, interval: int):
    """ 自动 """
    Auto.start(title_image=title, button_image=button, interval=interval)


@click.group()
@click.pass_context
def manage(ctx):
    pass


def command_register():
    manage.add_command(search)
    manage.add_command(profit)
    manage.add_command(auto_click)


if __name__ == '__main__':
    command_register()
    manage(obj={})
